package com.example.importDemo.controller;

import com.example.importDemo.model.Student;
import com.example.importDemo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DemoController {

    @Autowired
    private DemoService demoService;

    @RequestMapping("/boot/hello")
    public String hello () {
        return "Hello Spring Boot.";
    }

    @RequestMapping("/boot/getStudent")
    public List<Student> demo () {
        return demoService.getStudent();
    }

    @GetMapping("/boot/getStudentById/{id}")
    public List<Student> getStudentById (@PathVariable int id) {
        return demoService.getStudentById(id);
    }
}
